{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script type="text/javascript">
//<!CDATA[
function flex(obj)
{
    var status = obj.attr('status');
    var id = obj.attr('fieldid');
    var pid = obj.parent('td').parent('tr').attr("class");
    var src = $(obj).attr('src');
    if(status == 'open')
    {
        var pr = $(obj).parent('td').parent('tr');
        var selfurl = window.location.href;
        var sr  = pr.clone();
        var td2 = sr.find("td:eq(1)");
        td2.prepend("<img class='preimg' src='template/style/images/treetable/vertline.gif'/>")
                        .find("img[ectype=flex]")
                        .remove()
                        .end()
                        .find('span')
                        .remove();
        var img_count = td2.children("img").length;
        var td2html = td2.html();
         $.get(selfurl + "&act=ajax_cate", {id: id}, function(data){
             if(data)
             {
                 var str = '';
                 var add_child = '';
                 var res = eval('(' + data + ')');
                 for(var i = 0; i < res.length; i++)
                 {
                     if(res[i].switchs)
                     {
                         src =  "<img src='template/style/images/treetable/tv-expandable.gif' ectype='flex' status='open' fieldid="+res[i].fabric_type_id+
                           " onclick='flex($(this))'><span class='node_name'>" + res[i].fabric_type_name + "</span>";
                     }
                     else
                     {
                         src = "<img src='template/style/images/treetable/tv-item.gif'><span class='node_name'>" + res[i].fabric_type_name + "</span>";
                     }
                     if(img_count < 3)
                     {
                         add_child = "<a href='index.php?app=fabric_shop&amp;act=add_type&amp;pid="+res[i].fabric_type_id+"'>{$lang.add_child}</a>";
                     }
                     var itd2 = td2html + src;
                     str+="<tr class='"+pid+" row"+id+"'>"+
                        "<td class='node' width='50%'>" + itd2 + "</td>"+
                        "<td class='handler'><span><a href='index.php?app=fabric_shop&act=edit_type&id=" + res[i].fabric_type_id + "'>{$lang.edit}</a> | <a href='javascript:if(confirm("+'"{$lang.drop_confirm}"'+"))window.location=\"index.php?app=fabric_shop&act=drop_type&id=" + res[i].fabric_type_id + "\";'>{$lang.drop}</a> | " + add_child + "</span></td>";
                 }
                pr.after(str);
                $('span[ectype="inline_edit"]').unbind('click');
                $.getScript(SITE_URL+"/includes/libraries/javascript/inline_edit.js");
             }
         });
         obj.attr('src',src.replace("tv-expandable","tv-collapsable"));
         obj.attr('status','close');
    }
    if(status == 'close')
    {
        $('.row' + id).hide();
        obj.attr('src',src.replace("tv-collapsable","tv-expandable"));
        obj.attr('status','open');
    }
}

//]]>
</script>
<body>
<div class="sub-body" id="search_box">
    <h3 class="title-1" style="display:none;">{$lang.fabric_type_manage}</h3>
  <div class="tab_info" style="width: 700px">
  <div class="tab-title-1"><span>{$lang.fabric_type_manage}</span></div>
	<table width="700px" cellspacing="0" cellpadding="0" class="tab-display" id="tab-color1">
        <tr>
			<td colspan="2" align="right" style="padding-right:50px;"><a href="{url index.php?app=fabric_shop&act=add_type}" class="add btn-2">添加档口类型</a></td>
		</tr>
        <tr class="region_class">
            <th width="50%">{$lang.fabric_type_name}</th>
            <th class="handler">{$lang.handle}</th>
        </tr>
        <!--{foreach from=$fabric_type_list item=fabric_types}-->
        <tr>
            <td class="node" width="50%">
            <!--{if $fabric_types.switchs}-->
            <img src="template/style/images/treetable/tv-expandable.gif" ectype="flex" status="open" fieldid="{$fabric_types.fabric_type_id}" onclick="flex($(this))">
            <!--{else}-->
            <img src="template/style/images/treetable/tv-item.gif">
            <!--{/if}-->
            <span class="node_name">{$fabric_types.fabric_type_name|escape}</span></td>
            <td class="handler">
            <span>
            <a href="index.php?app=fabric_shop&amp;act=edit_type&amp;id={$fabric_types.fabric_type_id}">{$lang.edit}</a>
                |
                <a href="javascript:if(confirm('{$lang.drop_confirm}'))window.location = 'index.php?app=fabric_shop&amp;act=drop_type&amp;id={$fabric_types.fabric_type_id}';">{$lang.drop}</a><!-- {if $region.layer lt 4} --> | <a href="index.php?app=fabric_shop&amp;act=add_type&amp;pid={$fabric_types.fabric_type_id}">{$lang.add_child}</a><!-- {/if} -->
                </span>
                </td>
        </tr>
        <!--{foreachelse}-->
        <tr class="no_data">
            <td colspan="3">&nbsp;</td>
        </tr>
        <!--{/foreach}-->
    </table>
    {include file=page.html}
  </div>
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>